//
// CVideoCaptureFilter.cpp
//

#include "stdafx.h"
#include "CVideoCaptureFilter.h"

#include "GlobalDefs.h"
#include "UDsUtils.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

////////////////////////////////////////////////////////////////////////
CVideoCaptureFilter::CVideoCaptureFilter(IGraphBuilder * inGraph, 
										 const char * inDeviceName) 
: CDXFilter(inGraph, GUID_NULL, "Video Capture")
{
	if (inDeviceName)
	{
		strcpy(mDeviceName, inDeviceName);
	}
}

CVideoCaptureFilter::~CVideoCaptureFilter(void)
{
	ReleaseFilter();
}

BOOL CVideoCaptureFilter::CreateFilter(void)
{
	if (mFilter)
	{
		return TRUE;
	}

	if (mGraph)
	{
		mFilter = UDsUtils::CreateVideoDevice(mDeviceName);
		if (mFilter)
		{
			if (SUCCEEDED(mGraph->AddFilter(mFilter, mName)))
			{
				return TRUE;
			}
		}
	}

	ReleaseFilter();
	return FALSE;
}

void CVideoCaptureFilter::ReleaseFilter(void)
{
	CDXFilter::ReleaseFilter();
}